@import "@/style/variables.scss";

@function pxToRem($px) {
  @return $px/417 * 16rem;
}
@function rem($rpx) {
  @return $rpx/750 * 20rem;
}
@function cmSize($px) {
  @return $px/3/417 * 16rem;
}
@function cm2Size($px) {
  @return $px/390/2 * 16rem;
}

@mixin lborder($w) {
  border: $w solid $clightg;
}
@mixin bklcolor {
  background-color: $clightg;
}
@mixin bkscolor {
  background-color: #f0f6d4;
}
@mixin abs($x, $y) {
  position: absolute;
  transform: translate($x, $y);
}

@mixin angle($w, $color) {
  height: 0;
  width: 0;
  border: $w solid transparent;
  border-top-color: $color;
}
// 背景图片地址和大小
@mixin bis($url) {
  background-image: url($url);
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

@mixin borderRadius($radius) {
  -webkit-border-radius: $radius;
  -moz-border-radius: $radius;
  -ms-border-radius: $radius;
  -o-border-radius: $radius;
  border-radius: $radius;
}
//定位全屏
@mixin allcover {
  position: absolute;
  top: 0;
  right: 0;
}

@mixin center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

//定位上下居中
@mixin ct {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

//定位上下居中
@mixin cl {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

//宽高
@mixin wh($width, $height) {
  width: $width;
  height: $height;
}

//字体大小、行高、字体
@mixin font($size, $line-height, $family: "Microsoft YaHei") {
  font: #{$size}/#{$line-height} $family;
}

//字体大小，颜色
@mixin sc($size, $color) {
  font-size: $size;
  color: $color;
}

//flex 布局和 子元素 对其方式
@mixin fj($type: space-between) {
  display: flex;
  justify-content: $type;
}
@mixin triangle($width, $height, $color:$themeColor, $direction:right) {
  $width: $width/2;
  $color-border-style: rem($height) solid $color;
  $transparent-border-style: rem($width) solid transparent;
  height: 0;
  width: 0;
  @if $direction==up {
    border-bottom: $color-border-style;
    border-left: $transparent-border-style;
    border-right: $transparent-border-style;
  } @else if $direction==right {
    border-left: $color-border-style;
    border-top: $transparent-border-style;
    border-bottom: $transparent-border-style;
  } @else if $direction==down {
    border-top: $color-border-style;
    border-left: $transparent-border-style;
    border-right: $transparent-border-style;
  } @else if $direction==left {
    border-right: $color-border-style;
    border-top: $transparent-border-style;
    border-bottom: $transparent-border-style;
  }
}
